# 数据处理层Model，实现数据读取，写入
import json


def read_data(json_path):
    with open(json_path, mode='r', encoding='utf-8') as file:
        data = json.load(file)  # 反序列 化 含json格式的文件为 python对象
    return data


def write_data(data_list, json_path):
    with open(json_path, mode='w', encoding='utf-8') as file:
        json.dump(data_list, file, ensure_ascii=False)


if __name__ == '__main__':
    json_path = r'users.json'
    print(read_data(json_path))

    # user_list = [{"username": "zhangsan", "password": "123"}, {"username": "lisi", "password": "123"},
    #                  {"username": "wangwu", "password": "123"}]
    # write_data(user_list, json_path)
